package com.example.operation.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.operation.domin.SysBusinessArea;
import com.example.operation.dto.SysBusinessAreaDto;
import com.example.operation.service.SysBusinessAreaService;
import com.example.operation.utils.Result;
import com.example.operation.vo.SysBusinessAreaVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "业务区域设置模块")
@RestController
@RequestMapping("/sysBusinessArea")
public class SysBusinessAreaController {

    @Autowired
    private SysBusinessAreaService sysBusinessAreaService;


    @ApiOperation(value = "开通区域分页查询接口")
    @GetMapping("/page")
    public Result<Page<SysBusinessAreaController>> page(@RequestParam("pageNumber") @ApiParam(value = "当前页",required = true) Integer pageNumber,
                                                        @RequestParam("pageSize") @ApiParam(value = "分页条数",required = true) Integer pageSize,
                                                        @RequestParam(value = "name",required = false) @ApiParam(value = "当前页码") Integer name){
        Page<SysBusinessArea> page = sysBusinessAreaService.pageSBA(pageNumber,pageSize,name);
        return Result.ok(page);
    }


    @ApiOperation(value = "开通区域新增接口")
    @PostMapping("/save")
    public Result<String> save(@RequestBody SysBusinessAreaDto sysBusinessAreaDto){
        sysBusinessAreaService.insertSBA(sysBusinessAreaDto);
        return Result.ok("区域新增成功");
    }


    @ApiOperation(value = "开通区域删除接口")
    @DeleteMapping("/delect")
    public int delectById(@RequestParam("id") Integer id){
        return sysBusinessAreaService.delectById(id);
    }


//    @ApiOperation(value = "查询")
//    @GetMapping("/saveMap")
//    public Result<List<String>> saveMap(){
//        return Result.ok(sysBusinessAreaService.saveMap());
//    }

    @ApiOperation(value = "根据id查询接口")
    @GetMapping("/selectById")
    public Result<SysBusinessArea> selectById(@RequestParam(value = "id") Integer id){
        SysBusinessArea sysBusinessArea =sysBusinessAreaService.selectById(id);
        return Result.ok(sysBusinessArea);
    }


    @ApiOperation(value = "修改经纬度接口")
    @PutMapping("/update")
    public int update(@RequestBody SysBusinessAreaDto sysBusinessAreaDto){
        return sysBusinessAreaService.update(sysBusinessAreaDto);
    }

}
